<%@page isELIgnored="false" pageEncoding="UTF-8" contentType="text/html; UTF-8" %>

<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="test" style="width: 600px;height:400px;"></div>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.min1.3.5.js"></script>
<script src="${pageContext.request.contextPath}/js/echarts.min.js"></script>
<script src="${pageContext.request.contextPath}/js/china.js"></script>
<script type="text/javascript" src="https://cdn-hangzhou.goeasy.io/goeasy.js"></script>
<script type="text/javascript">
    // 1.基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('test'));

    // 2.指定图表的配置项和数据


    // 3.使用刚指定的配置项和数据显示图表。


    var goEasy = new GoEasy({
        appkey:"BC-bc0efc3ab30840fcbdc87e9222df0107"
    });
    goEasy.subscribe({
        channel:"my_channel",
        onMessage:function (message) {
            var count=JSON.parse(message.content);

            var option = {
                title: {
                        text: '用户男女比例'
                },
                tooltip: {},
                legend: {
                    data:['人数']
                },
                xAxis: {
                    data: ["男","女"]
                },
                yAxis: {},
                series: [{
                    name: '人数',
                    type: 'line',
                    data: count,
                }]
            };
            myChart.setOption(option)
        }
    });

</script>